import React from "react";
import {
  HashRouter as Router,
  Switch,
  Route,
  useHistory,
  useLocation,
  useParams,
} from "react-router-dom";

// url http://localhost:3000/#/home/123

function Home(props) {
  return (
    <div>
      Home
      <hr />
      {/* <Btn a={1} b={2} {...props}></Btn> */}
      <Btn></Btn>
    </div>
  );
}

function Btn() {
  // 使用路由相关钩子
  const history = useHistory();
  const location = useLocation();
  const params = useParams();
  console.log({ history, location, params });
  return <div>Btn</div>;
}

export default function App() {
  return (
    <>
      <div>
        <Router>
          <Switch>
            <Route path="/home/:abc" component={Home}></Route>
          </Switch>
        </Router>
      </div>
    </>
  );
}
